package com.xiaowen.tool;

import com.xiaowen.config.security.SmsCodeAuthenticationToken;
import com.xiaowen.user.entity.User;
import org.springframework.security.core.context.SecurityContextHolder;

/**
 * Created with IntelliJ IDEA.
 * User: yf-wenhao
 * Date: 2024/9/19
 * Time: 上午11:15
 */
public class UserContext {

    public static User getUser() {
        SmsCodeAuthenticationToken authentication = (SmsCodeAuthenticationToken) SecurityContextHolder.getContext().getAuthentication();
        return (User) authentication.getPrincipal();
    }

}
